This analysis explores oil spill incidents in California. Oil spill incident data are converted to spatial features and mapped over California’s county borders in an interactive Tmap. The data are also presented in a choropleth map to observe oil spill frequency by county.
Oil Spill Data Citation: Lampinen, Mark (2009). Oil Spill Incident Tracking [ds394]. California Department of Fish and Game, Office of Spill Prevention and Response. https://map.dfg.ca.gov/metadata/ds0394.html?5.108.39
California County Boundaries are sourced from the California Open Data Portal at: https://data.ca.gov/dataset/ca-geographic-boundaries/resource/b0007416-a325-4777-9295-368ea6b710e6
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)
library(tidyverse)
library(janitor)
library(here)
library(sf)
library(tmap)
library(tmaptools)
library(terra)
## reading in oil spill data
oil <- read_csv(here("data/Oil_Spill_Incident_Tracking_[ds394].csv")) %>%
clean_names()
## reading in county shapefile data and keeping only county name and geometry
counties <- read_sf(here("data/CA_Counties_TIGER2016.shp")) %>%
clean_names() %>%
select(name)
## converting oil spill data to sf
oil_sf <- st_as_sf(oil, coords = c("x", "y"),
crs = st_crs(counties)) # setting oil crs to match counties data
## checking to make sure crs matches
# st_crs(counties)
# st_crs(oil_sf)
## setting tmap mode and map style:
tmap_mode("view")
tmap_style("natural")
## mapping oil spill occurrences by CA county
tm_shape(counties) +
tm_polygons(alpha = 0) +
tm_shape(oil_sf) +
tm_dots(col = "salmon")